﻿package mortal.game.view.lookPlayerInfo.view
{
    import Message.DB.Tables.*;
    import Message.Game.*;
    import com.mui.controls.*;
    import com.mui.utils.*;
    import flash.utils.*;
    import mortal.game.resource.*;
    import mortal.game.resource.tableConfig.*;
    import mortal.game.view.lookPlayerInfo.*;
    import mortal.game.view.mount.newMountModuel.*;
    import mortal.game.view.skill.*;

    public class LookSystemSkillPart extends GSprite
    {
        protected var _slookPlayerMountInfo:SLookPlayerMountInfo;
        protected var _lookType:int;
        protected var _dicSkillItem:Dictionary;

        public function LookSystemSkillPart()
        {
            this._dicSkillItem = new Dictionary();
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            this.clearSkillList();
            this._slookPlayerMountInfo = null;
            super.disposeImpl(param1);
            return;
        }// end function

        protected function updateSkillList() : void
        {
            var _loc_2:TSkill = null;
            var _loc_4:TSkill = null;
            var _loc_6:OtherSkillItem = null;
            var _loc_7:TMountConfig = null;
            var _loc_8:TSkill = null;
            var _loc_9:SkillInfo = null;
            var _loc_11:int = 0;
            this.clearSkillList();
            var _loc_1:* = this._slookPlayerMountInfo.skillIds;
            var _loc_3:* = new Dictionary();
            var _loc_5:int = 0;
            while (_loc_5 < _loc_1.length)
            {
                
                _loc_2 = SkillConfig.instance.getInfoById(_loc_1[_loc_5]);
                _loc_4 = _loc_3[_loc_2.posType] as TSkill;
                if (_loc_4 == null || _loc_4 && _loc_2.skillLevel > _loc_4.skillLevel)
                {
                    _loc_3[_loc_2.posType] = _loc_2;
                }
                _loc_5++;
            }
            var _loc_10:* = this._slookPlayerMountInfo.code;
            _loc_5 = 0;
            while (_loc_5 < 10)
            {
                
                _loc_7 = MountConfig.instance.getMountInfoByCode((_loc_5 + 1), LookPlayerUtil.getConfigTypeByLookType(this._lookType));
                if (_loc_7 && _loc_7.skillList)
                {
                    _loc_9 = new SkillInfo();
                    _loc_8 = SkillConfig.instance.getInfoById(int(_loc_7.skillList));
                    _loc_9.tSkill = _loc_8;
                    _loc_6 = UICompomentPool.getUICompoment(OtherSkillItem);
                    _loc_6.setBg(ImagesConst.EquipItemBg, 7, 7);
                    _loc_6.setSize(48, 48);
                    _loc_6.x = 56 * _loc_11 + 73;
                    _loc_6.y = 18;
                    _loc_6.skillInfo = _loc_9;
                    _loc_6.setState(OtherSkillItem.stateType_no);
                    this._dicSkillItem[_loc_8.posType] = _loc_6;
                    this.addChild(_loc_6);
                    _loc_11++;
                    if (_loc_10 >= _loc_7.code)
                    {
                        _loc_6.isShowLock = false;
                        if (_loc_3[_loc_9.tSkill.posType])
                        {
                            _loc_9.tSkill = _loc_3[_loc_9.tSkill.posType];
                            _loc_6.skillInfo = _loc_9;
                            _loc_6.hasLearnSkill = true;
                        }
                        else
                        {
                            _loc_6.hasLearnSkill = false;
                        }
                    }
                    else
                    {
                        _loc_6.isShowLock = true;
                    }
                }
                _loc_5++;
            }
            return;
        }// end function

        protected function clearSkillList() : void
        {
            var _loc_1:OtherSkillItem = null;
            for each (_loc_1 in this._dicSkillItem)
            {
                
                _loc_1.dispose();
            }
            this._dicSkillItem = new Dictionary();
            return;
        }// end function

        public function setLookInfo(param1:SLookPlayerMountInfo, param2:int) : void
        {
            this._slookPlayerMountInfo = param1;
            this._lookType = param2;
            this.updateSkillList();
            return;
        }// end function

    }
}
